package edu.pw.p2pclient.utils;

import java.util.Comparator;
import java.util.Locale;

import edu.pw.p2pclient.data.Node;

public class NodeComparator implements Comparator<Node> {

	@Override
	public int compare(Node lhs, Node rhs) {

		if (!lhs.isFile() && rhs.isFile())
			return -1;
		if (lhs.isFile() && !rhs.isFile())
			return 1;
		return lhs.getName().toLowerCase(Locale.getDefault())
				.compareTo(rhs.getName().toLowerCase(Locale.getDefault()));
	}
}
